﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Xunit;
using Moq;
using CoolCode.Entities;
using CoolCode.Services;
using Kangxin.Mvc.Controllers;
using Kangxin.Mvc.Models;

namespace Kangxin.Mvc.Controllers.Tests
{
    public class HomeControllerTest
    {
        [Fact]
        public void Login()
        {
            HomeController controller = new HomeController(); 
            ViewResult result = controller.Login() as ViewResult; 
            ViewDataDictionary viewData = result.ViewData;
            Assert.NotNull(viewData);
            Assert.IsType(typeof(LoginModel), viewData.Model); 
            //Assert.Equal(false, (bool)viewData["RememberMe"]);
        }

        [Fact]
        public void LoadMenu()
        {
            var mockMenuService = new Mock<IMenuService>();
            mockMenuService.Setup(p => p.ListMenu(It.IsAny<string>())).Returns(new ModuleList());
            HomeController controller = new HomeController(mockMenuService.Object);
            ViewResult result = controller.LoadMenu() as ViewResult;
            ViewDataDictionary viewData = result.ViewData;
            Assert.NotNull(viewData);
            
            Assert.IsType(typeof(JsonResult), result );
            Assert.Equal("{}", result.ToString());
            //Assert.Equal(false, (bool)viewData["RememberMe"]);
        }
    }
}
